<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>02 key的作用</title>
  </head>
  <body>
    <p id="num">0</p>
  </body>
  <script>
    //DOM操作次数 ：90000->3次
    console.time("start");
    let num = document.querySelector("#num"); //1次DOM
    let n = num.innerHTML; //1次DOM
    for (let i = 0; i < 30000; i++) {
      n++;
    }
    num.innerHTML = n; //1次DOM
    console.timeEnd("start"); //143.781005859375ms => 2.444091796875ms
  </script>
</html>
